package com.dhc.appbusinessfrm.network;

import com.dhc.appbusinessfrm.App;

import javax.inject.Inject;

import retrofit.ErrorHandler;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;

/**
 * Created by xy on 2015/5/20.
 */
public class NetAdapterWrapper {

    public NetAdapterWrapper(String webServicesUrl){
        App.getObjectGraph().inject(this);
        this.webServicesUrl=webServicesUrl;
    }

    /**
     * webservices url
     */
    private String webServicesUrl=null;


    @Inject
    RequestInterceptor requestInterceptor;

    @Inject
    ErrorHandler errorHandler;

   public RestAdapter getRestAdapter(){
       return new RestAdapter.Builder()
               .setEndpoint(webServicesUrl)
               .setErrorHandler(errorHandler)
               .setLogLevel(RestAdapter.LogLevel.FULL)
               .setRequestInterceptor(requestInterceptor)
               .build();
    }
}
